package com.zimmor.utils;

import java.io.*;

/**
 * 加密文件的程序
 */
public class EncryptFile {
    public static void main(String[] args){
        FileInputStream fileInputStream = null;
        FileOutputStream fileOutputStream = null;
        try{
            fileInputStream = new FileInputStream("E:/a.jpg");
            fileOutputStream = new FileOutputStream("E:/a1.dat");
            int buff= -1;
            int temp = -1;
            boolean flag = false;
            while((buff = fileInputStream.read()) != -1){
                if(flag) {
                    fileOutputStream.write(buff);
                    fileOutputStream.write(temp);
                    flag = false;
                } else {
                    temp = buff;
                    flag = true;
                }
            }
            fileInputStream.close();
            fileOutputStream.close();
        }catch (Exception e) {
            e.printStackTrace();
        }finally {
            try {
                fileInputStream.close();
                fileOutputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }

        }

    }

}
